﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BO = Viewer.BusinessObject.BusinessEntities;
using Ext.Net;
namespace Viewer.NguoiDung.UserControls
{
    public partial class UCNguoiDung : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadData();
            }
        }
        public void LoadData()
        {
            storeHr.DataSource = new BO.QUNguoiDung().LoadData();
            storeHr.DataBind();
        }
        protected void btnAddNew_Click(object sender, DirectEventArgs e)
        {
            ucAddNew.ShowAddNewDialog();
        }
        [DirectMethod]
        public void ShowEditDialog(int ID, string type)
        {
            if (type.Equals("Delete"))
            {
                BO.QUNguoiDung query = new Viewer.BusinessObject.BusinessEntities.QUNguoiDung();
                query.DeleteNguoiDung(ID);
                LoadData();
            }
            else
            {
                UcDetail.ShowDialog(ID, type);
            }
            X.Mask.Hide();
        }
        protected void btnSearch_Click(object sender, DirectEventArgs e)
        {
            storeHr.DataSource = new BO.QUNguoiDung().SearchNguoiDung(txtName.Text);
            storeHr.DataBind();
            X.Mask.Hide();
        }
    }
}